Controller area network (CAN) data links are used in a number of industries, such as the automotive industries, for providing bus connections between simple industrial devices, such as sensors or actuators, and higher-level devices, such as an electronic control module (ECM). Each message on the data link has an associated identifier. The identifier may specify one or more particular nodes to which the message is directed; alternatively, the identifier may identify the message as a broadcast message for all nodes. Each node needs to determine if it is interested in each incoming message, based at least in part on the identifier. For example, in the SAE J1939 CAN standard, an identifier may include a message priority field, a source ID, a destination ID, and a parameter group number (PGN). The source and destination IDs are correspond to the nodes sending the message and the nodes to which the message is directed; the PGN is related to the information content.
Typically, the determination by the node of whether that node is interested in a particular incoming message involves comparing an incoming message identifier with each of the defined identifiers associated with the node. These defined identifiers may be stored as match registers or receive registers. The comparison operation may require significant processing overhead. One disadvantage of this operation is that the significant processing overhead may limit the throughput associated with the data link Further, the processor may not have time to perform any other computations required.
One method to overcome this disadvantage is to provide filtering via one or more mask registers. Rather than comparing each incoming message with each of the match registers, the message is first compared to a mask register to determine if the message can be ignored, thus saving the processing time associated with comparing the message to each match register. Mask registers are typically included in CAN interface hardware. Mask registers are set up to indicate which bits of an incoming identifier must be matched to at least one of the defined identifiers in order for a message to be received, and thereby generate an interrupt. Using mask registers thus saves processing time and overhead by reducing the number of messages that need to be compared.
One known method for using mask registers for processing received messages is described in U.S. Pat. No. 5,958,029. This system uses a single comparator circuit and a direct memory access (DMA) controller for comparing an identifier associated with the incoming message against a set of match registers (or defined identifiers for the nodes) based on a plurality of mask registers.
Regardless of the method used for comparing the identifier associated with the incoming message and the match registers, it is important that the mask register be set up accurately to avoid unnecessary processor overhead. In particular, ineffective mask registers may allow the inclusion of too many messages, including messages not directed at a particular node, causing wasted processor time and excessive interrupts. On the other hand, a mask register that excludes a message directed to a particular node, or excludes a broadcast message, may result in improper operation of the system.
One challenge in setting up mask registers results from the arbitrary method in which identifiers may be set. For example, the SAE J1939 CAN protocol identifiers may include a message priority field, a source ID, a destination ID, and a PGN, as described above. The identifiers are then assigned in numerical order. This assignment method, therefore, is not intended to optimize any sort of masking.
The present invention is directed to overcoming one or more of the problems or disadvantages associated with the prior art.